<?php
session_start ();
// 判断用户是否已经登录
if (! isset ( $_SESSION ["userinfo"] ) and empty ( $_SESSION ["userinfo"] ["userid"] )) {
	session_unset ();
	session_destroy ();
	header ( "location:../index.php" );
	exit ();
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Language" content="zh-CN">
<link href="./Resource/Style/base.yy.css" rel="stylesheet"
	type="text/css">
</head>
<body>
<?php
$myid = $_SESSION ["userinfo"] ["userid"];
// $myid = "xufeng520";
$myname = $_SESSION ["userinfo"] ["username"];
// $myname = "许峰";
require_once '../tools/SqlHelper.class.php';
if (isset ( $_GET ['dazhaohu'] )) {
	// 获取浏览器发过来的页面数据
	$user_id = $_GET ['dazhaohu'];
	$user_name_d = $_GET ['user_name'] . "你好，很高兴认识你！！";
	// 创建一个SqlHelper对象
	$sql = "INSERT INTO `message_tb` (`user_receiver_id`, `user_send_id`, `ms_content`) VALUES ('$user_id', '$myid', '$user_name_d')";
	$sqlHelper = new SqlHelper ();
	$res = $sqlHelper->execute_dql ( $sql );
	if (! ! $res) {
		echo "<script>alert('向" . $_GET ['user_name'] . "打招呼成功')</script>";
	} else {
		echo "<script>alert('向" . $_GET ['user_name'] . "打招呼失败')</script>";
	}
}
// $sql = "select user_id,ps_profession,ps_birthday_year,ps_apartment,ps_Icon from `personal_data_tb` where 1=1";
$sql = "select user_id,ps_profession,ps_birthday_year,ps_apartment,ps_Icon from `personal_data_tb` where `ps_sex` <> (select ps_sex from `personal_data_tb` where `user_id` = '$myid')";
// 创建一个SqlHelper对象
$sqlHelper = new SqlHelper ();
$row = $sqlHelper->execute_dql ( $sql );
$now_data = getdate ();
?>
	<div class="hi_succeed list_hi">
		<h2 style="background-color: #FF83AD;">
			<strong>亲，今天已有<font id="peopleCount">近10万</font>人通过每日姻缘找到对象！守株待“缘”，不如主动出击
			</strong> <a href="./baseData.php"
				style="color: #fff; font-size: 16px;">跳过，进入我的资料</a>
		</h2>
		<div class="hi_info">
<?php
while ( $res = mysql_fetch_assoc ( $row ) ) {
	$user_id = $res ['user_id'];
	$ps_profession = $res ['ps_profession'];
	$ps_birthday_year = $res ['ps_birthday_year'];
	$ps_apartment = $res ['ps_apartment'];
	if ($ps_apartment == "0") {
		$ps_apartment = "未填写";
	} else {
		preg_match_all ( "/./u", $ps_apartment, $arr );
		$ps_apartment = $arr [0] [0] . $arr [0] [1];
	}
	$ps_Icon = $res ['ps_Icon'];
	if ($ps_Icon == "0") {
		$ps_Icon = "../PersonalPhoto/Images/nohead_new.jpg";
	} else {
		$ps_Icon = "../PersonalPhoto/" . $user_id . "/" . $ps_Icon;
	}
	$sql2 = "select user_name from `user_tb` where `user_id`='$user_id'";
	$row2 = $sqlHelper->execute_dql ( $sql2 );
	$res2 = mysql_fetch_array ( $row2 );
	$user_name_w = $res2 ['user_name'];
	$ps_birthday_year = ($now_data ["year"] - ( int ) $ps_birthday_year);
	
	echo "<p class='userItem'>";
	echo "<a target='new' class='a_content' href='../PersonalSpace/PersonalSpace.php?user_id=" . $user_id . "'>";
	echo "<img alt='" . $user_name_w . "的个人空间' width='84' height='105' src='" . $ps_Icon . "' />";
	echo "</a>";
	echo "<a target='new' class='name' href='../PersonalSpace/PersonalSpace.php?user_id=" . $user_id . "' title='" . $user_name_w . "'>" . $user_name_w . "</a>";
	echo "<span>" . $ps_birthday_year . "岁</span><span>" . $ps_apartment . "</span>";
	echo "<font><a class='hi sayHiBtn' style='background-color: #FF83AD;' href='./today.php?dazhaohu=" . $user_id . "&user_name=" . $user_name_w . "'>打招呼</a></font>";
	echo "</p>";
}
?>
		</div>
		<div class="all_hi">
			<a id="allSayHiBtn" href="#" style="background-color: #FF83AD;">全部打招呼</a>
		</div>
	</div>
</body>
</html>